package cn.edu.imau.zy.examination.controller;

import java.util.List;
import java.util.Arrays;


import cn.edu.imau.zy.examination.domain.ElExamDepart;
import cn.edu.imau.zy.examination.service.IElExamDepartService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.edu.imau.zy.common.annotation.LoginUser;
import cn.edu.imau.zy.common.core.entity.system.SysUser;
import cn.edu.imau.zy.common.core.domain.R;
import cn.edu.imau.zy.common.core.controller.BaseController;

/**
 * 考试部门 提供者
 * 
 * @author xsc
 * @date 2021-08-04
 */
@RestController
@RequestMapping("depart")
public class ElExamDepartController extends BaseController
{
	
	@Autowired
	private IElExamDepartService elExamDepartService;
	
	/**
	 * 查询${tableComment}
	 */
	@GetMapping("get/{id}")
	public ElExamDepart get(@PathVariable("id") String id)
	{
		return elExamDepartService.getById(id);
	}

	@GetMapping("depaById/{id}")
	public R getDepaById(@PathVariable("id") String id){

		QueryWrapper<ElExamDepart> wrapper = new QueryWrapper<>();
		wrapper.eq("depart_id",id);
		return result(elExamDepartService.list(wrapper));
	}
	
	/**
	 * 查询考试部门列表
	 */
	@GetMapping("list")
	public R list(ElExamDepart elExamDepart)
	{
		startPage();
        return result(elExamDepartService.queryList(elExamDepart));
	}
	
	
	/**
	 * 新增保存考试部门
	 */
	@PostMapping("save")
	public R addSave(@RequestBody ElExamDepart elExamDepart,@LoginUser SysUser user)
	{
//		elExamDepart.setCreateBy(user.getUserId().toString());
		return toAjax(elExamDepartService.save(elExamDepart));
	}

	/**
	 * 修改保存考试部门
	 */
	@PostMapping("update")
	public R editSave(@RequestBody ElExamDepart elExamDepart,@LoginUser SysUser user)
	{
//		elExamDepart.setUpdateBy(user.getUserId().toString());
		return toAjax(elExamDepartService.updateById(elExamDepart));
	}
	
	/**
	 * 删除${tableComment}
	 */
	@PostMapping("remove")
	public R remove(String ids)
	{		
		return toAjax(elExamDepartService.removeById(ids));
	}
	
}
